 
var orderManage = function() {

	var _init = function() {

		var table = $('#table_order');

		var tableUnit=table.dataTable({
			"processing": true,
			// 开启服务器模式
			serverSide: true,
			"ajax": {
				url:"/a/wxconf/comm/totals"
			},
			"autoWidth": false,
			"columns": [
			
				{
					"width": "12%",//买家
					"data": "nickName",
					"render": function(data, type, row, meta) {
						if(data){
							return data;
						}else{
							return "未绑定微信昵称";
						}
					}
				},	{
					"width": "12%",//手机号
					"data": "mobile",
					"render": function(data, type, row, meta) {
						if(data){
							return data;
						}else{
							return "未绑定手机";
						}
					}
				},{
						"width": "10%",
						"data": "directShareNums",
						"render": function(data, type, row, meta) {
							if(data){
								return data;
							}else{
								return "0";
							}
						}
				},{
					"width": "10%",
					"data": "directShareQunNums",
					"render": function(data, type, row, meta) {
						if(data){
							return data;
						}else{
							return "0";
						}
					}
			},
				{
					"width": "9%",
					"data":"directBindNums",
					"render": function(data, type, row, meta) {
						if(data){
							return data;
						}else{
							return "0";
						}
					}
					
				},
				{
					"width": "9%",
					"data": "totalIncome" ,
					"render": function(data, type, row, meta) {
						return data/100
					}
					
				}
				,
				
				{
					"width": "7%",
					"data": "totalWithdrawals",
					"render": function(data, type, row, meta) {
						return data/100
					}

				},{
					"width" : "10%",
					"data" : "null",
				    "defaultContent" : "<button type=\"button\" class=\"btn btn_profit\">收益</button><button type=\"button\" class=\"btn btn_commission\">提现</button>"


				}
				],
				"language": {
					url: '/assets/pages/Chinese.json'
				},
				"pageLength": 10,
				"order":false,
				/*"order": [
					[0, "desc"]
					],*/
					"columnDefs": [{
						"orderable": false,
						"targets": [0,1,2,3,4,5,6,7]
					}],
            "dom": "<'row'<'.col-md-6 col-sm-12'><'col-md-6 col-sm-12'>r>" +
            "<t>" +
            "<'row'<'col-md-5'i><'col-md-7'>p>",
            "fnInitComplete": function() {},
           /* "fnDrawCallback": function(){
            }*/
		});


		//用户动态查询
		$('#doQuery').click(function(event){
			var name =   $("#search input[name='name']").val();
			var phone =   $("#search input[name='phone']").val();
			var param={"nickName":name,"mobile":phone};
			table.DataTable().search(JSON.stringify(param)).draw();
		});

		// 查看收益明细
		table.on('click', '.btn_profit', function(event) {
			var oData_arr = table.DataTable().rows($(this).parents("tr"))
			.data(); // 操作行对象
			var uperUserId = oData_arr[0].id;
			window.location.href="/p/wxconf/comm/profit?uperUserId="+ encodeURIComponent(uperUserId);

		});
		// 提现明细
		table.on('click', '.btn_commission', function(event) {
			var oData_arr = table.DataTable().rows($(this).parents("tr"))
			.data(); // 操作行对象
			var uperUserId = oData_arr[0].id;
			window.location.href="/p/wxconf/comm/commission?uperUserId="+ encodeURIComponent(uperUserId);
		});

							
	}

	return {
		init: function() {
			_init();
		}

	};

}();



$(function() {
	orderManage.init();
});